<script type="text/javascript">
    var root_path = '<?php echo _SITE_ADMIN_URL_?>';
    var table = 'services_master';
    var field = 'name';
    var item_col = 'id';
    var item_value = '<?php echo $_REQUEST['id'];?>';
            		
	$(document).ready(function(){
        
        $('#name').keyup
        $('#name').change
        $('#name').keydown
        (function(){
                var field_value = $(this).val();
                path = root_path+'ajax/getGeo.php?type=check_availability&table='+table+'&field='+field+'&field_value='+field_value+'&item_col='+item_col+'&item_value='+item_value;
                $.ajax({url: path,    
                    success: function(response) {
                        $('#availability_loading').hide();
                        $('#availability_info').html(response);
                    }
                });
            });
        
		$('#category').change(function(){
			var category = $(this).val();
			path = root_path+'ajax/getGeo.php?id='+category+'&type=subcategory';
			$.ajax({url: path,	
				success: function(response) {
					$('#subcategory').html(response);
				}
			});
			
		});
		
		$('#subcategory').change
        $('#subcategory').keyup
        (function(){
			var subcategory = $(this).val();
			path = root_path+'ajax/getGeo.php?id='+subcategory+'&type=subcategory';
			$.ajax({url: path,	
				success: function(response) {
					$('#subsubcategory').html(response);
				}
			});
			
		});
        
        $('#subsubcategory').change
        $('#subsubcategory').keyup
        (function(){
            var category = $(this).val();
            path = root_path+'ajax/getGeo.php?id='+category+'&type=getattribute&item_id='+item_value;
            $.ajax({url: path,    
                success: function(response) {
                    $('#attributes').html(response);
                }
            });
            
        });
        
	});
    
    function loadAttribute(){
            var category = $("#subsubcategory").val();
            path = root_path+'ajax/getGeo.php?id='+category+'&type=getattribute&item_id='+item_value;
            $.ajax({url: path,    
                success: function(response) {
                    $('#attributes').html(response);
                }
            });
    }
        
</script>
<!-- Example table -->
<div class="container_12"> 
    <div class="module">
        <h2><span><?php echo $_title; ?></span></h2>
        <div class="module-body">
			<div style="margin-top:13px;">
                <?php
				if(isset($errMsg)){?>
                    <span class="notification"><?php echo $_MESSESGE[$errMsg];?></span>
                <?php }?>
			</div>
                        
            <form id="adminForm" name="admin_frm" action="" method="post" enctype="multipart/form-data">
				<p>
					<label>Sub Sub Category: <strong>
                    <?php echo $subsubcat['name'];?></strong>
                    <input type="hidden" value="<?php echo $subsubcat['id'];?>" name="subsubcategory" id="subsubcategory"></label>
				</p>
				<p>
					<label>Service Name</label>
					<div id="availability_info"></div>
					<input type="text" class="input-short" name="name" id="name" value="<?php echo $result['name'];?>" />
					<!--  <span class="notification-input ni-correct">This is correct, thanks!</span> -->
				</p>
                <!--
                <p>
                    <label>Service Attributes</label>
                    <p id="attributes"></p>
                </p>                
				 
				<div id="service_attr_list" style="display:block">
                    <?php
                    $strcontent ='';
                    foreach($service_attributes as $key => $val){ 
                        echo $strcontent ='<p><label>'.$val['attribute_name'].'</label><input type="text" class="input-short" name="attributes['.$val['attribute_id'].']['.$val['attribute_name'].']" value="'.$val[attribute_value].'"/>&nbsp;'.$val['unit'].'</p>';
                    }?>
                </div>
                -->
				<p>
					<label>Service Description</label>
					<?php $editor->editor('description', $result['description']) ;?>
				</p>
				
				<p>
					<label>Service Tags</label>
					<input type="text" class="input-short" name="tags" value="<?php echo $result['tags'];?>" />
					<!--  <span class="notification-input ni-correct">This is correct, thanks!</span> -->
				</p> 
				<fieldset>
					<input type="hidden" class="input-short" name="id" value="<?php echo $result['id'];?>" />
					<input class="submit-green" type="submit" name="submit" value="Submit" /> 
				   <input class="submit-gray" type="button" value="Cancel" onclick="javascript: window.location='<?php echo _SITE_ADMIN_URL_?>'+'master/service_mng.php';" />
				</fieldset>
			</form>
		</div> <!-- End .module-body -->
	</div>  <!-- End .module -->
</div>
<div style="clear:both;"></div>
<script type="text/javascript">
	jQuery.validator.addMethod(
		"selectCategoryNone",
		function(value, element) {
			if (element.value == ""){
				return false;
			}
			else return true;
		},
		"Please select a category."
	);
	jQuery.validator.addMethod(
		"selectSubCategoryNone",
		function(value, element) {
			if (element.value == ""){
				return false;
			}
			else return true;
		},
		"Please select a sub category."
	);
	jQuery.validator.addMethod(
		"selectSubSubCategoryNone",
		function(value, element) {
			if (element.value == ""){
				return false;
			}
			else return true;
		},
		"Please select a sub sub category."
	);
	jQuery.validator.addMethod(
		"selectServiceAttributesNone",
		function(value, element) {
			if (element.value == ""){
				return false;
			}
			else return true;
		},
		"Please select service attributes."
	);
	
	$().ready(function() {
		$("#adminForm").validate({
			rules: {
				category: {
					selectCategoryNone: true
				},
				subcategory: {
					selectSubCategoryNone: true
				},
				subsubcategory: {
					selectSubSubCategoryNone: true
				},
				name: "required",
				description: "required",
				"attributes[]": {
					selectServiceAttributesNone: true
				},
				tags: "required"
			 },
			messages: {
				name: "Please enter service name",
				description: "Please enter service description",
				tags: "Please enter service tags"
			}
		});
	});
    //loadAttribute();
</script>